//
// Created by xili on 2024/8/3 14:31.
// Go big or go home.
//
#include <vector>
#include <unordered_map>

using namespace std;

class Solution {
public:
    int findLucky(vector<int> &arr) {
        unordered_map<int, int> ump;
        for (auto &item: arr) {
            ump[item]++;
        }
        int ans = -1;
        for (auto &item: ump) {
            if (item.first == item.second) {
                ans = max(ans, item.second);
            }
        }
        return ans;
    }
};